import yagmail


def send(to_addr, code):
    try:
        yag = yagmail.SMTP(user='feiandtao0402@qq.com', password='nqrtiifuwojqdgeh', host='smtp.qq.com', port='465')
        body = f'您的验证码为{code}，如非本人操作，请忽略此条邮件'
        yag.send(headers={'From':'陶陶涵官方账号','To':'用户'}, to=f'{to_addr}', subject='陶陶涵注册验证码',
                 contents=[body])
        return True
    except:
        return False

